// 🎨 简单颜色测试脚本
// 在浏览器控制台中运行此脚本来测试颜色分配

console.log('🎨 开始简单颜色测试...')

// 检查全局对象
console.log('检查全局对象:')
console.log('- window.colorDebugger:', !!window.colorDebugger)
console.log('- window.gameStore:', !!window.gameStore)

// 检查 GameStore 状态
if (window.gameStore) {
  console.log('\n📊 GameStore 当前状态:')
  console.log('- currentPlayer:', window.gameStore.currentPlayer)
  console.log('- players:', window.gameStore.players)
  console.log('- currentRoom:', window.gameStore.currentRoom)
  console.log('- isConnected:', window.gameStore.isConnected)
} else {
  console.log('❌ GameStore 未找到')
}

// 测试颜色分配
function testColorAssignment() {
  console.log('\n🧪 测试颜色分配...')
  
  if (!window.gameStore) {
    console.log('❌ GameStore 不可用')
    return
  }
  
  // 检查当前玩家
  const currentPlayer = window.gameStore.currentPlayer
  if (currentPlayer) {
    console.log('当前玩家:', {
      id: currentPlayer.id,
      nickname: currentPlayer.nickname,
      avatarColor: currentPlayer.avatarColor,
      brushColor: currentPlayer.brushColor
    })
    
    if (currentPlayer.brushColor) {
      console.log('✅ 当前玩家有画笔颜色:', currentPlayer.brushColor)
    } else {
      console.log('❌ 当前玩家没有画笔颜色')
    }
  } else {
    console.log('❌ 没有当前玩家')
  }
  
  // 检查玩家列表
  const players = window.gameStore.players
  if (players && players.length > 0) {
    console.log('\n玩家列表:')
    players.forEach((player, index) => {
      console.log(`${index + 1}. ${player.nickname}:`, {
        avatarColor: player.avatarColor,
        brushColor: player.brushColor
      })
    })
    
    // 检查颜色是否不同
    const brushColors = players.map(p => p.brushColor).filter(c => c)
    const uniqueColors = new Set(brushColors)
    
    if (brushColors.length === uniqueColors.size) {
      console.log('✅ 所有玩家都有不同的画笔颜色')
    } else {
      console.log('❌ 有重复的画笔颜色')
      console.log('画笔颜色列表:', brushColors)
      console.log('唯一颜色数量:', uniqueColors.size)
    }
  } else {
    console.log('❌ 玩家列表为空')
  }
}

// 运行测试
console.log('\n🚀 运行测试...')
testColorAssignment()

console.log('\n✨ 测试完成！')
console.log('💡 如果看到问题，请确保：')
console.log('1. 页面已完全加载')
console.log('2. 已连接到 SignalR 服务器')
console.log('3. 已创建或加入房间')
console.log('4. 后端服务器正在运行')
